home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Franz PD / Franz PD Disk #324 (1994-04)(Rhein-Sieg-Soft).zip / Franz PD Disk #324 (1994-04)(Rhein-Sieg-Soft).adf / VideoText3.5 / source / decode.p < prev    next >
Text File  |  1994-04-01  |  6KB  |  175 lines

  1. UNIT decode; {$project vt}
  2. { Zeichensatzkonvertierung zum Programm VideoText }
  3.  
  4. INTERFACE; FROM vt USES global;
  5.  
  6. PROCEDURE makeascii(source: p_onepage; zeile: integer; farblos: boolean;
  7.                     var asciicode: str80);
  8. PROCEDURE decode_line(source: p_onepage; zeile: integer; verdeckt: boolean;
  9.                       VAR amigacode: bigstring; VAR dblheight: Boolean);
  10. VAR blank40: String[41];
  11.  
  12. { ---------------------------------------------------------------------- }
  13.  
  14. IMPLEMENTATION;
  15. {$opt q,s+,i+}
  16.  
  17. VAR notascii: Array[32..127] OF Byte; STATIC;
  18.     vt_to_ascii, vt_to_myfont: Array[0..7] OF String[15]; STATIC;
  19.     j: Integer;
  20.  
  21. PROCEDURE makeascii{(source: p_onepage; zeile: integer; farblos: boolean;
  22.                     var asciicode: str80)};
  23. { Eine Zeile einer VT-Seite für Drucker- oder Dateiausgabe umwandeln. }
  24. { Für <farblos>=false werden Farbcodes nicht einfach weggeworfen, sondern }
  25. { durch Klartext '\0' .. '\7'  umschrieben. }
  26. var thisbyte: byte;
  27.     start, spalte, i: integer;
  28.     grafik: boolean;
  29.     group8,group32,country: byte;
  30. begin
  31.   if source=Nil then
  32.     asciicode := blank40
  33.   else begin
  34.     country := (source^.cbits SHR 12) AND $07;
  35.     start := zeile*40;
  36.     grafik := false;
  37.     i := 1;
  38.     for spalte := 0 to 39 do begin
  39.       thisbyte := source^.chars[start+spalte];
  40.       group8 := thisbyte SHR 3;   { 8er-Gruppe }
  41.       group32 := group8 SHR 2;   { 32er-Gruppe }
  42.       if group8=0 then  grafik := false;
  43.       if group8=2 then  grafik := true;
  44.       IF (group32=2) OR (NOT grafik AND (group32 in [1..3])) THEN
  45.         { druckbares Zeichen, über Tabellen decodieren }
  46.         IF notascii[thisbyte]>0 THEN
  47.           asciicode[i] := vt_to_ascii[country][notascii[thisbyte]]
  48.         ELSE
  49.           asciicode[i] := chr(thisbyte)
  50.       ELSE
  51.         asciicode[i] := ' ';
  52.       if NOT farblos AND (group8=0) then begin    { Farbcode als Klartext }
  53.         asciicode[i] := '\'; Inc(i); asciicode[i] := chr(thisbyte+ord('0'));
  54.       end;
  55.       Inc(i);
  56.     end;
  57.     asciicode[i] := chr(0);
  58.   end;
  59. end;
  60.  
  61. {$opt i-}
  62. PROCEDURE decode_line{(source: p_onepage; zeile: integer; verdeckt: boolean;
  63.                       VAR amigacode: bigstring; VAR dblheight: Boolean)};
  64. { Setzt eine Zeile Teletextzeichen (40 Zeichen) in eine String für den }
  65. { Amiga um (bis zu 160 Zeichen, leider), mit ANSI-Steuerzeichen, für meinen }
  66. { teletext.font. }
  67. { Stringfunktionen absichtlich vermieden, soll vor allem schnell sein! }
  68. var farbe, country, thisbyte, lastout, group32: byte;
  69.     grafik, hold, geheim: boolean;
  70.     start,spalte,i: integer;
  71. begin
  72.   country := (source^.cbits SHR 12) AND $07;
  73.   farbe := 7;
  74.   grafik := False;
  75.   hold := False;
  76.   geheim := False;
  77.   dblheight := False;
  78.   i := 1;
  79.   start := zeile*40;
  80.   for spalte := 0 to 39 do begin
  81.     thisbyte := source^.chars[start+spalte] AND $7F;
  82.     if thisbyte<32 then begin  { Steuerzeichen }
  83.       geheim := false;
  84.       if thisbyte=30 then hold := true;
  85.       if thisbyte=31 then hold := false;
  86.       if hold then begin
  87.         amigacode[i] := chr(lastout); inc(i);
  88.       end;
  89.       case thisbyte of
  90.         0..7: begin { neue Textfarbe }
  91.           grafik := false;
  92.           farbe := thisbyte;
  93.           amigacode[i] := #155; inc(i);
  94.           amigacode[i] := '3';  inc(i);
  95.           amigacode[i] := chr(farbe+48); inc(i);
  96.           amigacode[i] := 'm';  inc(i);
  97.         end;
  98.         {8: begin { Blinken (d. h. revers) ein }
  99.           amigacode[i] := #155; inc(i);
  100.           amigacode[i] := '7';  inc(i);
  101.           amigacode[i] := 'm';  inc(i);
  102.         end;}
  103.         {9: begin { Blinken aus }
  104.           amigacode[i] := #155; inc(i);
  105.           amigacode[i] := '0';  inc(i);
  106.           amigacode[i] := 'm';  inc(i);
  107.         end;}
  108.         13: dblheight := True; { doppelthohe Zeichen }
  109.         16..23: begin { neue Grafikfarbe }
  110.           grafik := true;
  111.           farbe := thisbyte-16;
  112.           amigacode[i] := #155; inc(i);
  113.           amigacode[i] := '3';  inc(i);
  114.           amigacode[i] := chr(farbe+48); inc(i);
  115.           amigacode[i] := 'm';  inc(i);
  116.         end;
  117.         24: geheim := true;
  118.         28: begin { Hintergrund schwarz }
  119.           amigacode[i] := #155; inc(i);
  120.           amigacode[i] := '4';  inc(i);
  121.           amigacode[i] := '0';  inc(i);
  122.           amigacode[i] := 'm';  inc(i);
  123.         end;
  124.         29: begin { Zeichenfarbe als Hintergrund }
  125.           amigacode[i] := #155; inc(i);
  126.           amigacode[i] := '4';  inc(i);
  127.           amigacode[i] := chr(farbe+48); inc(i);
  128.           amigacode[i] := 'm';  inc(i);
  129.         end;
  130.         otherwise;
  131.       end;
  132.       if not hold then begin
  133.         amigacode[i] := ' '; inc(i);
  134.       end;
  135.     end else begin { druckbares Zeichen }
  136.       IF grafik AND NOT (thisbyte IN [64..95]) THEN
  137.         thisbyte := thisbyte + 128
  138.       ELSE IF notascii[thisbyte]>0 THEN
  139.         thisbyte := ord(vt_to_myfont[country][notascii[thisbyte]]);
  140.       if (geheim and verdeckt) then
  141.         amigacode[i] := ' '
  142.       else
  143.         amigacode[i] := chr(thisbyte); inc(i);
  144.       lastout := thisbyte;
  145.     end;
  146.   end;
  147.   amigacode[i] := chr(0);
  148. end;
  149. {$opt i+}
  150.  
  151. BEGIN   { Initialisierungsteil }
  152.   { VT-Zeichensatzdekodierung }
  153.   { Welche (druckbaren) Zeichen müssen überhaupt dekodiert werden? }
  154.   FOR j := 32 TO 127 DO notascii[j] := 0;
  155.   FOR j := 0 TO 1 DO notascii[35+j] := 1+j;
  156.   notascii[64] := 3;
  157.   FOR j := 0 TO 5 DO notascii[91+j] := 4+j;
  158.   FOR j := 0 TO 3 DO notascii[123+j] := 10+j;
  159.   { Durch welche Zeichen werden sie ersetzt, a) im Standard-Amiga-Zeichensatz, }
  160.   { b) in meinem videotext.font? }
  161.   { Die Ländernummern (aus den Steuerbits als C12 + 2*C13 + 4*C14 berechnet) }
  162.   { sind: 0=England, 1=Frankreich, 2=Schweden, 3=reserviert, 4=Deutschland, }
  163.   { 5=Spanien, 6=Italien, 7=reserviert. }
  164.   vt_to_ascii[0] := '£$@«½»^#­¼|¾÷'; vt_to_myfont[0] := 'Á$ÀÂÈÄÃ#-ÇÅÉÆ'; { GB }
  165.   vt_to_ascii[1] := 'éïàëêùî#èâôûç'; vt_to_myfont[1] := 'Ô×ÎÔÕÝØ#ÓÐÜßÒ'; { F }
  166.   vt_to_ascii[2] := '#¤ÉÄÖÅÜ_éäöåü'; vt_to_myfont[2] := '#ÌE[\Í]_Ô{|Ñ}'; { S }
  167.   vt_to_ascii[3] := '£$@«½»^#­¼|¾÷'; vt_to_myfont[3] := 'Á$ÀÂÈÄÃ#-ÇÅÉÆ'; { ?? }
  168.   vt_to_ascii[4] := '#$§ÄÖÜ^_°äöüß'; vt_to_myfont[4] := '#$@[\]^_`{|}~'; { D }
  169.   vt_to_ascii[5] := 'ç$¡áéíóú¿üñèà'; vt_to_myfont[5] := 'Ò$ÊÏÔ×ÛÞË}ÙÓÎ'; { E }
  170.   vt_to_ascii[6] := '£$é°ç»^#ùàòèì'; vt_to_myfont[6] := 'Á$Ô`ÒÄÃ#ÝÎÚÓÖ'; { I }
  171.   vt_to_ascii[7] := '£$@«½»^#­¼|¾÷'; vt_to_myfont[7] := 'Á$ÀÂÈÄÃ#-ÇÅÉÆ'; { ?? }
  172.   FOR j := 1 TO 40 DO blank40[j] := ' ';
  173.   blank40[41] := #0;
  174. END.
  175.